/**
 * @(#)SimulatorListenController.java 2017年2月18日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jsbd.boss.domian.channel.ClientHeartBeat;
import org.jsbd.boss.domian.channel.ClientTaskInfo;
import org.jsbd.boss.service.ISimulatorListenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

/**
 * 模拟器监听类
 * @author <a href="mailto:zhouchao@xingbook.com" >周超</a>
 * @version 1.0.0
 */

@Controller
@RequestMapping("/client/heartbeat")
public class ClientHeartBeatController {
	public static final Logger LOGGER = LoggerFactory.getLogger(ClientHeartBeatController.class);
    
	@Autowired
	private ISimulatorListenService simulatorListenService;
	
	@RequestMapping(value = "/listen")
	@ResponseBody
	public String heartBeatListen(ClientHeartBeat heartBeat,HttpServletRequest request, HttpServletResponse resp) {
		LOGGER.info("heartBeat is [{}]",heartBeat);
		ClientTaskInfo taskInfo=simulatorListenService.getTask(heartBeat);
		return JSON.toJSONString(taskInfo);
	}

}
